package eclipse.weibo.modle.control;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import eclipse.weibo.util.ReadImageUtil;

public class ImageLabel extends Label {
    public final static int THUMBNAIL_PIC = 0;
    public final static int BMIDDLE_PIC = 1;
    public final static int ORIGINAL_PIC = 2;

    private int showType = 0;
    private String thumbnail_pic = "";
    private String bmiddle_pic = "";
    private String original_pic = "";

    public ImageLabel(Composite parent, int style, String thumbnail_pic, String bmiddle_pic, String original_pic) {
        super(parent, style);
        this.thumbnail_pic = thumbnail_pic;
        this.bmiddle_pic = bmiddle_pic;
        this.original_pic = original_pic;
    }

    public String getThumbnail_pic() {
        return thumbnail_pic;
    }

    public void setThumbnail_pic() {
        if (thumbnail_pic != null && thumbnail_pic.length() > 0) {
            setPic(thumbnail_pic);
            showType = THUMBNAIL_PIC;
        }
    }

    public int getShowType() {
        return showType;
    }

    public String getBmiddle_pic() {
        return bmiddle_pic;
    }

    public void setBmiddle_pic() {
        if (bmiddle_pic != null && bmiddle_pic.length() > 0) {
            setPic(bmiddle_pic);
            showType = BMIDDLE_PIC;
        }
    }

    public String getOriginal_pic() {
        return original_pic;
    }

    public void setOriginal_pic() {
        if (original_pic != null && original_pic.length() > 0) {
            setPic(original_pic);
            showType = ORIGINAL_PIC;
        }
    }

    private void setPic(String picUrl) {
        ImageData imageData = ReadImageUtil.read(picUrl);
        Image img = new Image(this.getDisplay(), imageData);
        this.setImage(img);
    }

    protected void checkSubclass() {

    }
}
